﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace BilingualSentSearchEngine
{
    class SentencePairValidation
    {
    //    HashSet<string> hashSetSentence = new HashSet<string>();
    //    Dictionary<string, int> query2cnt = new Dictionary<string, int>();
        StreamWriter swSent;
        object _privateObject = new object();

        public SentencePairValidation(string strFileName)
        {
            lock (_privateObject)
            {
                //if (File.Exists(strFileName) == true)
                //{
                //    StreamReader srSent;
                //    srSent = new StreamReader(strFileName);
                //    while (srSent.EndOfStream == false)
                //    {
                //        string strEnglishSentence, strChineseSentence;
                //        strEnglishSentence = srSent.ReadLine();
                //        strChineseSentence = srSent.ReadLine();
                //        srSent.ReadLine();
                //        srSent.ReadLine();

                //        hashSetSentence.Add(strEnglishSentence);
                //    }
                //    srSent.Close();
                //}

                swSent = new StreamWriter(strFileName, true);
            }

        }

        //public int GetSentencePairNumOfQuery(ref string strQuery)
        //{
        //    if (query2cnt.ContainsKey(strQuery) == false)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return query2cnt[strQuery];
        //    }
        //}

        public void AddBadSentencePair(ref string strQuery, ref string strEnglishSentence, ref string strChineseSentence)
        {
            lock (_privateObject)
            {
         //       if (hashSetSentence.Contains(strEnglishSentence) == false)
        //        {
                    swSent.WriteLine(strEnglishSentence);
                    swSent.WriteLine(strChineseSentence);
                    swSent.WriteLine();
                    swSent.WriteLine();
                    swSent.Flush();

                //    hashSetSentence.Add(strEnglishSentence);
                //}

                //if (query2cnt.ContainsKey(strQuery) == true)
                //{
                //    query2cnt[strQuery]++;
                //}
                //else
                //{
                //    query2cnt[strQuery] = 1;
                //}
            }
        }

        //public bool Validate(string strSentence)
        //{
        //    lock (_privateObject)
        //    {
        //        if (hashSetSentence.Contains(strSentence) == true)
        //        {
        //            return false;
        //        }

        //        return true;
        //    }
        //}
    }
}
